<!DOCTYPE html>
<html>
<head>
	<title>222</title>
	<script src="jq.js"></script>
</head>
<body>
	<p id="content">
		log:
	</p>
	<input  id="inp">
	<button id="btn1">发送</button>
</body>
<script type="text/javascript">

	var worker = new SharedWorker('sharedWorker.js');
	worker.port.start();
	worker.port.postMessage({msg:'ping'})
	var num = 0
	$('#btn1').click(function(){
		var val = $('#inp').val()
		worker.port.postMessage({msg:"["+ num +"]"+ val})
		num+=1
	}) 
	worker.port.addEventListener('message', function(e){
		$('#content').html( $('#content').html() + '<br>' + e.data.msg)
	}, false);
</script>
</html>